The Sharing Tab - #5704
Conversation
42072dd to
6eca7f7
Compare
6c721e6 to
1069815
Compare
|
I'm going to move this one back to draft because in a downstream branch I moved all of this to lua and simplified some things to make testing sharing_modes easier. Will backport isolated bits of that PR if it fails to merge. That approach has some downsides (like a lack of a schema validation in the CI), but those are compensated for with types and specs. |
1069815 to
78f64cf
Compare
78f64cf to
ef0b26f
Compare
8400bc2 to
f3fbabc
Compare
1f8f474 to
819511a
Compare
Test Results20 tests +4 10 ✅ +3 17s ⏱️ +14s For more details on these failures, see this check. Results for commit ce774d4. ± Comparison against base commit cf64f44. ♻️ This comment has been updated with latest results. |
c819af1 to
a29702b
Compare
…ring
Renames spec/builders/{spring->engine}_{,un}synced_builder.lua + their
builder_specs, Builders.Spring->Builders.EngineSynced,
Builders.SpringUnsynced->Builders.EngineUnsynced, @Class names, and all
call sites. The renamed builders own every Engine-related test edit so no
two prereqs touch one file:
- engine_synced_builder.lua: gamedata/system.lua defs mock aliases
Engine.{Shared,Synced,Unsynced} + BAR to the _G.Spring/_G.BAR mocks
- engine_unsynced_builder.lua: widget sandbox gets env.Engine; capture
spies install on Engine.Shared.*
Prefix branch -> lands in fmt once, every leaf+mig inherits it.
Recovered from origin/mig-spring-split@4e25bfe82a (branch lost in a rename);
files transplanted verbatim (formatting is normalized by run_fmt).
Add Utilities, I18N, Debug, Lava, and GetModOptionsCopy to the System tables in luaui/system.lua and luarules/system.lua so that widgets and gadgets can access them after detach-bar-modules moves them off the Spring table. Also create .emmyrc.json (the EmmyLua analyzer config) with the detached modules in the globals list, plus type stubs for LSP/CLI support. The .emmyrc.json content matches what vscode-recommended-extensions ships, with 5 extra globals (Utilities/Debug/Lava/GetModOptionsCopy/I18N) that only become real top-level identifiers after detach-bar-modules runs. When vscode-recommended-extensions has already merged, -Xtheirs in the cherry-pick keeps this version (the superset). # Conflicts: # .emmyrc.json
Restructures the 20 files under luaui/Tests/, luaui/TestsExamples/,
plus the headless-only common/testing/infologtest.lua, from bare-
global hook declarations to a return-table shape. Updates the
dbg_test_runner widget to read test hooks from the returned table.
Motivation: the pre-existing shape required the test files to run
under setfenv(chunk, testEnvironment) and define `function test()`,
`function setup()`, etc. as bare module-level globals that setfenv
redirected into the environment. That works at runtime but emmylua
can't model the sandboxing — it sees 20+ files declaring project-
wide globals like `test`, `setup`, `skip`, `cleanup`. To keep
emmylua happy, .emmyrc.json had to blacklist both test directories
under workspace.ignoreDir — a kludge on clearly-ours code. Lives on
its own leaf so the convention change can be discussed in isolation.
Minimal shape change per file — just prepend `local` to each top-
level `function` declaration, and append a final `return { ... }`
block listing whichever lifecycle hooks (skip/setup/test/cleanup)
that file actually defines. Original indentation and formatting
preserved (no stylua reformatting noise — the fmt transform runs
after this one in the mig pipeline).
Runner patch — luaui/Widgets/dbg_test_runner.lua, loadTestFromFile:
- capture the return value of pcall(chunk)
- require it to be a table
- merge its keys into testEnvironment so runTestInternal still
reads bare `skip`/`setup`/`test`/`cleanup` under setfenv
Vendored LuaCATS annotations for busted/luassert to provide IntelliSense for the unit-test surface. Lives on its own leaf so the discussion around 'vendoring LuaCATS types' can happen in isolation — prior pushback on the same direction in an earlier unit-testing PR makes this the right place to litigate it rather than burying it in a broader env commit. Why vendored instead of declared as a Lux dep: Lux does not yet support pulling LuaCATS annotations from library deps, and quick attempts to wire this up in Lux failed. Upstream tracking issue: lumen-oss/lux#953 — once that lands, these directories should be deleted in favor of declaring busted as a normal Lux dev-dep. Sources (pinned SHAs): - types/busted/ https://github.com/LuaCATS/busted @ 5ed85d0e016a5eb5eca097aa52905eedf1b180f1 - types/luassert/ https://github.com/LuaCATS/luassert @ d3528bb679302cbfdedefabb37064515ab95f7b9 See types/busted/provenance.md and types/luassert/provenance.md for per-directory upstream refs + license status.
…ixes Human-curated environment that, together with the LLM type-triage pass (fmt-llm), drives emmylua_check to zero on the migrated tree. Per-change rationale lives in PR beyond-all-reason#7447 review comments. - .emmyrc.json globals + diagnostics; types/* stubs; busted mock; CI gate - forward-decl / assertEqual declarations; reverted orphaned kikito loader - rationale-comment strip; types/IntegrationTests rename - deterministic pins for type-triage leftovers the LLM mishandles on big files (multi_attack opts, HighlightUnit forward-decl, ripairs suppress, gui_pip gameFrame use-before-declare) - json.lua forward-decl tidy (relocate null, drop dead decode_scan*) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
IsDevModeCached (upstream beyond-all-reason#6918) references `utilities` inside its own table constructor, where the local is not yet in scope — Lua resolves those reads as GLOBALS, so the first real call would index nil. Dormant today only because nothing calls it. Forward-declare the local so the closure captures it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0.22.0's analyzer resolves a local inside its own table constructor, so constructor-self-reference globals — a real dormant-crash class (see the springFunctions.lua fix) — passed CI silently. 0.24.0 catches them; the whole workspace surfaces exactly the four occurrences of that one bug, fixed in the previous commit, so the stricter gate lands green. Also tracks the upstream release asset rename (arm64 -> aarch64). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
gui_flowui.lua: Draw.Button uses `opaque` — Draw.Element's 17th parameter, which Button never had; the global read was always nil. Pinned false (behavior-identical) until upstream decides whether Button should expose an opaque mode. snd_notifications.lua: `customNotifications` is persisted by GetConfigData but never declared or assigned anywhere. Declared nil so the round-trip is explicit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Generated by parallel claude-sonnet-4-6 workers dispatched by scripts/codemod/llm-type-triage.sh, applying fixes per SKILL.md categories. Single pass, no iteration — categories that don't shrink the count are a signal that SKILL.md needs a new rule.
|
Superseded by #8406 — recreated with its head on beyond-all-reason instead of the fork (no fork-headed PRs; branch content identical, review history stays readable here). |
|
The design writeup, mode documentation, related-work links, and merge plan from this PR now live in the feature tracking issue: #8412. Review and merge proceed on native stack #8411 (#8125 → #8126 → #8407 → #8062 → #8063 → #8064 → #8095, with #8408 on top). The QA and design discussion history stays here. |
Moved
Moved to Issue and stacked PR: #8412
📚 Reviewed via the file-partitioned split — bottom-up
Important
This PR is the merge vehicle for the whole feature — review happens in the split PRs above. Its tree is byte-identical to the assembled split tip. Merge order: the type-migration stack (#8235) lands first; then this PR's base flips to
master(the diff doesn't change — the stack is already built on the migrated base) and it merges through the GitHub UI. The split PRs are closed afterwards; their content is contained here.Each PR is file-partitioned: every file appears in exactly one PR in its final
sharing_tabform, so each PR's diff is byte-identical to that branch. Regenerated deterministically byjust bar::sharing-split.Related work
!modecommands in battle chat teiserver#1280📚 Stacked split— review bottom-up
Each PR merges into the one below it; together they reproduce the
sharing_tabbranch (bar one intentional change —index.lualazy-loads the mode helpers).The idea
The engine stops being the economy authority and becomes the economy data plane for team redistribution. It keeps measuring (income, pull, expense, per-frame excess) and exposes that state through an API. A registered synced-Lua controller pulls a snapshot on its own cadence, runs redistribution, and writes back its own economy stats directly. Unit transfers, team giveaways (
GiveEverythingTo), and/takeare replaced by game-side gadgets; native overflow sharing is the one piece behind a flag —nativeExcessSharing = falsehands it to the Lua controller.On top of that boundary, sharing is configured by modes — named presets that set, lock, and hide the individual modoptions. The lobby (Chobby) presents them; the game enforces them. Each modoption stays cardinal (one knob, one behavior) so modes compose them freely.
Modes
Enabled (default) — all sharing on, no tax. Today's game, unchanged.

Disabled — no unit or resource sharing

Easy Tax — anti-co-op preset. Taxes resource sharing, assist, and resurrection; gifted eco buildings are stunned and mobile constructors build-delayed, so you can't dodge the tax by handing over production.

/takeruns on a stun delay.Tech Core — tech levels gate what you can build; you raise your level by constructing Keystone buildings. Unit sharing and resource tax both scale with tier (e.g. constructors become shareable at T2; tax eases as you climb).

/takeruns on a 60s delay for Resource buildings (the Take Delay Category in the screenshot below).Customize — every knob editable; roll your own policy.
Note: This is the one mode that preserves the previous mode's values when switching to it, so you can switch from tech core to customize and customize will behave exactly like tech core.
For players and mode developers, Customize provides a lot of benefits for this design:
Other changes
/takemoved into the game (was engine-native), which is what enables the delay/category take modes above.Demos
LLM usage
Tons of AI usage, but this started on much earlier models so I really had to beat it into shape and the code is clearly my style of decompositional functional programming, and that doesn't happen accidentally.